import { get, post, put, _delete } from '@/lin/plugin/axios'

/**
 * 统一订单相关API
 * 现在所有订单都需要使用支付凭证交易
 */
export default class UnifiedOrderApi {
  /**
   * 获取订单列表（支持类型过滤）
   */
  static async getOrderPage(params) {
    return await get('v1/unified-order/list', params)
  }

  /**
   * 获取订单详情
   */
  static async getOrderDetail(id) {
    return await get(`v1/unified-order/${id}`)
  }

  /**
   * 获取待支付审核的订单列表
   */
  static async getPaymentPendingOrders(params) {
    return await get('v1/unified-order/payment-pending', params)
  }

  /**
   * 获取订单支付审核详情
   */
  static async getPaymentDetail(id) {
    return await get(`v1/unified-order/payment-detail/${id}`)
  }

  /**
   * 确认订单支付
   */
  static async confirmPayment(id, data) {
    return await post(`v1/unified-order/confirm-payment/${id}`, data)
  }

  /**
   * 拒绝订单支付
   */
  static async rejectPayment(id, data) {
    return await post(`v1/unified-order/reject-payment/${id}`, data)
  }

  /**
   * 获取订单支付审核统计
   */
  static async getPaymentStats() {
    return await get('v1/unified-order/payment-stats')
  }

  /**
   * 批量确认支付
   */
  static async batchConfirmPayment(data) {
    return await post('v1/unified-order/batch-confirm-payment', data)
  }

  /**
   * 批量拒绝支付
   */
  static async batchRejectPayment(data) {
    return await post('v1/unified-order/batch-reject-payment', data)
  }

  /**
   * 获取订单分页列表（简化版）
   */
  static async getOrderPageSimple(params) {
    return await get('v1/unified-order/page', params)
  }

  /**
   * 搜索订单
   */
  static async searchOrders(params) {
    return await get('v1/unified-order/search', params)
  }

  /**
   * 修改订单状态
   */
  static async changeOrderStatus(id, status) {
    return await put('v1/unified-order/status', { id, status })
  }

  /**
   * 获取订单详情（简化版）
   */
  static async getOrderDetailSimple(id) {
    return await get(`v1/unified-order/${id}/detail`)
  }
}

// 导出具体的方法（保持向后兼容）
export const getVipPaymentPendingOrders = UnifiedOrderApi.getPaymentPendingOrders
export const getVipPaymentDetail = UnifiedOrderApi.getPaymentDetail
export const confirmVipPayment = UnifiedOrderApi.confirmPayment
export const rejectVipPayment = UnifiedOrderApi.rejectPayment
export const getVipPaymentStats = UnifiedOrderApi.getPaymentStats
export const batchConfirmVipPayment = UnifiedOrderApi.batchConfirmPayment
export const batchRejectVipPayment = UnifiedOrderApi.batchRejectPayment

// 导出新的统一API方法
export const getOrderPage = UnifiedOrderApi.getOrderPage
export const getOrderDetail = UnifiedOrderApi.getOrderDetail
export const getPaymentPendingOrders = UnifiedOrderApi.getPaymentPendingOrders
export const getPaymentDetail = UnifiedOrderApi.getPaymentDetail
export const confirmPayment = UnifiedOrderApi.confirmPayment
export const rejectPayment = UnifiedOrderApi.rejectPayment
export const getPaymentStats = UnifiedOrderApi.getPaymentStats
export const batchConfirmPayment = UnifiedOrderApi.batchConfirmPayment
export const batchRejectPayment = UnifiedOrderApi.batchRejectPayment
export const getOrderPageSimple = UnifiedOrderApi.getOrderPageSimple
export const searchOrders = UnifiedOrderApi.searchOrders
export const changeOrderStatus = UnifiedOrderApi.changeOrderStatus
export const getOrderDetailSimple = UnifiedOrderApi.getOrderDetailSimple 